from game import zz_game
from zz import zz_log, zz_img

log = zz_log.of()


class Game(zz_game.ZZ_Game):
    def __init__(self, d, has_prize=True):
        super().__init__(d, has_prize)

    def get_name(self):
        return "茶叶蛋大冒险"

    def game_alert(self):
        self.alert_close_by_file("./game/img/茶叶蛋大冒险")

    def check_done(self):
        return False

    def jump(self):
        self.log_msg("跳")
        self.d.click(2234, 1058)

    def rigth(self, duration):
        self.log_msg(f"右: {duration}")
        self.d.long_click(768, 1065, duration)

    def handle_main(self):
        self.log_msg("等待进入开始游戏界面")
        self.img_exit('./game/img/茶叶蛋大冒险/game_start.png', 100)
        self.log_msg("已进入开始游戏界面,点击开始游戏")
        self.img_click('./game/img/茶叶蛋大冒险/game_start.png')
        self.log_msg("等待进入游戏主界面")
        self.img_exit('./game/img/茶叶蛋大冒险/game_main.png', 100)
        self.log_msg("已进入游戏主界面")

        self.img_click_if_exists("点击主线关卡", './game/img/茶叶蛋大冒险/play.png', './game/img/茶叶蛋大冒险/play_01.png')
        self.img_click_if_exists("点击关卡1", './game/img/茶叶蛋大冒险/play_01.png', './game/img/茶叶蛋大冒险/play_main.png')

        self.log_msg("开始挑战关卡")
        self.jump()
        self.rigth(1.45)
        self.jump()
        self.rigth(2)
        
        self.d.sleep(3)
        self.game_alert()

        return True
